drop procedure if exists RSBUGT.MESSAGES_GET_COUNT;
go

create procedure RSBUGT.MESSAGES_GET_COUNT()
begin
    select count(*) as MSG_COUNT from RSBUGT.MESSAGES where USER_ID = @current_user_id;  
end;
go

grant execute on procedure RSBUGT.MESSAGES_GET_COUNT to 'RSUSR'@'%';
go